
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Elasticsearch查询性能提升 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="cache.html" />
    
    
    <link rel="prev" href="security.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../techstack/">
            
                <a href="../techstack/">
            
                    
                    技术栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    快速开始
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../helloworld/SYSTEM.html">
            
                <a href="../helloworld/SYSTEM.html">
            
                    
                    建立一个系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../helloworld/CORE.html">
            
                <a href="../helloworld/CORE.html">
            
                    
                    选定后台体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html">
            
                    
                    创建一个实体
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#实体的定义">
            
                    
                    实体的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#发布Entity">
            
                    
                    发布Entity
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.2.1" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#Service接口">
            
                    
                    Service接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2.2" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#SQL数据库存储模式">
            
                    
                    SQL数据库存储模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2.3" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#MongoDB存储模式">
            
                    
                    MongoDB存储模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2.4" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#ServiceAPI存储模式">
            
                    
                    ServiceAPI存储模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2.5" data-path="../helloworld/ENTITY.html">
            
                <a href="../helloworld/ENTITY.html#筛选器">
            
                    
                    筛选器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../helloworld/API.html">
            
                <a href="../helloworld/API.html">
            
                    
                    发布一个服务接口
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.1" data-path="../helloworld/API.html">
            
                <a href="../helloworld/API.html#服务接口的定义">
            
                    
                    服务接口的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2" data-path="../helloworld/API.html">
            
                <a href="../helloworld/API.html#发布Microserice">
            
                    
                    发布Microserice
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.2.1" data-path="../helloworld/API.html">
            
                <a href="../helloworld/API.html#REST接口">
            
                    
                    REST接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.2" data-path="../helloworld/API.html">
            
                <a href="../helloworld/API.html#DTO参数">
            
                    
                    DTO参数
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../helloworld/APP.html">
            
                <a href="../helloworld/APP.html">
            
                    
                    创建一个应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="../helloworld/APP.html">
            
                <a href="../helloworld/APP.html#应用的定义">
            
                    
                    应用的定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2" data-path="../helloworld/APP.html">
            
                <a href="../helloworld/APP.html#应用的发布">
            
                    
                    应用的发布
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.2.1" data-path="../helloworld/APP.html">
            
                <a href="../helloworld/APP.html#前端代码">
            
                    
                    JS前端代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2.2" data-path="../helloworld/APP.html">
            
                <a href="../helloworld/APP.html#Gateway">
            
                    
                    Gateway
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    开发环境设置
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../dev/IDE.html">
            
                <a href="../dev/IDE.html">
            
                    
                    配置开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../dev/ENV.html">
            
                <a href="../dev/ENV.html">
            
                    
                    开发环境使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../dev/CFG.html">
            
                <a href="../dev/CFG.html">
            
                    
                    管理配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../dev/ARG.html">
            
                <a href="../dev/ARG.html">
            
                    
                    常规应用参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../dev/PORT.html">
            
                <a href="../dev/PORT.html">
            
                    
                    通用端口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../dev/FB.html">
            
                <a href="../dev/FB.html">
            
                    
                    前后端分离
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../dev/DOCKER.html">
            
                <a href="../dev/DOCKER.html">
            
                    
                    Docker和Docker Compose
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    微服务
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../msa/">
            
                <a href="../msa/">
            
                    
                    概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../msa/GW.html">
            
                <a href="../msa/GW.html">
            
                    
                    Gateway
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../msa/BUS.html">
            
                <a href="../msa/BUS.html">
            
                    
                    服务治理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../msa/OU.html">
            
                <a href="../msa/OU.html">
            
                    
                    运行时-ibzou用户管理微服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../msa/WF.html">
            
                <a href="../msa/WF.html">
            
                    
                    运行时-ibzwf工作流微服务
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    选项
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="security.html">
            
                <a href="security.html">
            
                    
                    安全
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.2" data-path="es.html">
            
                <a href="es.html">
            
                    
                    Elasticsearch查询性能提升
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="cache.html">
            
                <a href="cache.html">
            
                    
                    使用Redis的两级缓存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../publish/companyserver.html">
            
                <a href="../publish/companyserver.html">
            
                    
                    使用Logback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../publish/companyserver.html">
            
                <a href="../publish/companyserver.html">
            
                    
                    使用Druid
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="dynamicDS.html">
            
                <a href="dynamicDS.html">
            
                    
                    dynamic datasource多数据源
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../publish/companyserver.html">
            
                <a href="../publish/companyserver.html">
            
                    
                    使用xxl-job任务调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="transactional.html">
            
                <a href="transactional.html">
            
                    
                    使用seata分布式事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="rocketmq.html">
            
                <a href="rocketmq.html">
            
                    
                    使用RocketMQ
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../other/EX.html">
            
                <a href="../other/EX.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../end/">
            
                <a href="../end/">
            
                    
                    结束
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Elasticsearch查询性能提升</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="elasticsearch">Elasticsearch</h1>
<p>&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x57FA;&#x4E8E;&#x4F60;&#x7684;&#x6570;&#x636E;&#x5E93;&#x63D0;&#x4F9B;&#x9AD8;&#x7EA7;&#x641C;&#x7D22;&#x80FD;&#x529B;&#xFF0C;&#x53EF;&#x4EE5;&#x5F00;&#x542F;Elasticsearch&#x652F;&#x6301;&#x3002;&#x7CFB;&#x7EDF;&#x5728;&#x5F00;&#x542F;es&#x652F;&#x6301;&#x540E;&#xFF0C;&#x9664;&#x4E86;&#x8FDB;&#x884C;&#x5B9E;&#x4F53;&#x81EA;&#x8EAB;&#x5B58;&#x50A8;&#x5916;&#xFF0C;&#x8FD8;&#x4F1A;&#x5C06;&#x5B58;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#x5B58;&#x5165;&#x5230;es&#x4E2D;&#xFF0C;&#x4EE5;&#x4F9B;&#x540E;&#x7EED;&#x68C0;&#x7D22;&#x3002;</p>
<h3 id="&#x5B9E;&#x4F53;&#x5F00;&#x542F;es&#x652F;&#x6301;">&#x5B9E;&#x4F53;&#x5F00;&#x542F;es&#x652F;&#x6301;</h3>
<p><img src="../img/es_config.png" alt="img"></p>
<p>&#x5F53;&#x7CFB;&#x7EDF;&#x5728;&#x5F00;&#x542F;es&#x652F;&#x6301;&#x540E;&#xFF0C;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x5957;es&#x7684;do&#x3001;service&#x3001;dao</p>
<p>do&#x5B9E;&#x4F53;&#x7C7B;: &#x751F;&#x6210;&#x4E00;&#x4E2A;es domain&#x7C7B;&#xFF0C;&#x5C5E;&#x6027;&#x4E0E;&#x6807;&#x51C6;do&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#xFF0C;&#x4E0D;&#x652F;&#x6301;&#x5173;&#x7CFB;&#x3002;</p>
<pre><code class="lang-java">
<span class="hljs-meta">@Getter</span>
<span class="hljs-meta">@Setter</span>
<span class="hljs-meta">@NoArgsConstructor</span>
<span class="hljs-meta">@JsonIgnoreProperties</span>(value = <span class="hljs-string">&quot;handler&quot;</span>)
<span class="hljs-meta">@Document</span>(indexName = <span class="hljs-string">&quot;sample&quot;</span>, type = <span class="hljs-string">&quot;human&quot;</span>, shards = <span class="hljs-number">5</span>, replicas = <span class="hljs-number">1</span>)
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Human</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">EntityMP</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Serializable</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">long</span> serialVersionUID = <span class="hljs-number">1L</span>;
    <span class="hljs-comment">/**
     * &#x4EBA;&#x7C7B;&#x6807;&#x8BC6;
     */</span>
    <span class="hljs-meta">@Audit</span>
    <span class="hljs-meta">@DEField</span>(isKeyField=<span class="hljs-keyword">true</span> , value = <span class="hljs-string">&quot;humanid&quot;</span>)
    <span class="hljs-meta">@JSONField</span>(name = <span class="hljs-string">&quot;humanid&quot;</span>)
    <span class="hljs-meta">@JsonProperty</span>(<span class="hljs-string">&quot;humanid&quot;</span>)
    <span class="hljs-meta">@Id</span>
    <span class="hljs-keyword">private</span> String humanid;
    <span class="hljs-comment">/**
     * &#x66F4;&#x65B0;&#x4EBA;
     */</span>
    <span class="hljs-meta">@DEField</span>(name = <span class="hljs-string">&quot;updateman&quot;</span> , preType = DEPredefinedFieldType.UPDATEMAN)
    <span class="hljs-meta">@Field</span>(type = FieldType.Text)
    <span class="hljs-meta">@JSONField</span>(name = <span class="hljs-string">&quot;updateman2&quot;</span>)
    <span class="hljs-meta">@JsonProperty</span>(<span class="hljs-string">&quot;updateman2&quot;</span>)
    <span class="hljs-keyword">private</span> String updateman2;
    <span class="hljs-comment">/**
     * &#x4EBA;&#x7C7B;&#x540D;&#x79F0;2
     */</span>
    <span class="hljs-meta">@Audit</span>
    <span class="hljs-meta">@DEField</span>(value = <span class="hljs-string">&quot;humanname&quot;</span>,dict=<span class="hljs-string">&quot;YesNoStr&quot;</span>)
    <span class="hljs-meta">@Field</span>(type = FieldType.Text)
    <span class="hljs-meta">@JSONField</span>(name = <span class="hljs-string">&quot;humanname&quot;</span>)
    <span class="hljs-meta">@JsonProperty</span>(<span class="hljs-string">&quot;humanname&quot;</span>)
    <span class="hljs-keyword">private</span> String humanname;

}
</code></pre>
<p>service&#x5B9E;&#x73B0;&#xFF1A;&#x9A71;&#x52A8;Repository&#x5B8C;&#x6210; Get&#xFF0C;Create&#xFF0C;Update&#xFF0C;Remove&#xFF0C;&#x5229;&#x7528;QueryBuilder&#x5B8C;&#x6210;&#x7ED3;&#x679C;&#x96C6;&#x67E5;&#x8BE2;&#x5C55;&#x73B0;</p>
<pre><code class="lang-java">
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HumanServiceImpl</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IHumanService</span> </span>{

    <span class="hljs-meta">@Autowired</span>
    HumanRepository  repository;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Human <span class="hljs-title">get</span><span class="hljs-params">(String key)</span> </span>{
        Optional&lt;Human&gt; result = repository.findById(key);
        <span class="hljs-keyword">if</span>(!result.isPresent()){
            Human et=<span class="hljs-keyword">new</span> Human();
            et.setHumanid(key);
            <span class="hljs-keyword">return</span> et;
        }
        <span class="hljs-keyword">else</span>{
            Human et=result.get();
            <span class="hljs-keyword">return</span> et;
        }
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">create</span><span class="hljs-params">(Human et)</span> </span>{
        repository.save(et);
        CachedBeanCopier.copy(get(et.getHumanid()),et);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">update</span><span class="hljs-params">(Human et)</span> </span>{
        repository.save(et);
        CachedBeanCopier.copy(get(et.getHumanid()),et);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">remove</span><span class="hljs-params">(String key)</span> </span>{
        repository.deleteById(key);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Page&lt;Human&gt; <span class="hljs-title">searchDefault</span><span class="hljs-params">(HumanSearchContext context)</span> </span>{
        Iterable&lt;Human&gt; list= repository.search(context.getEsCond());
        List&lt;Human&gt; entities = Lists.newArrayList(list);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> PageImpl&lt;Human&gt;(entities,context.getPageable(),entities.size());
    }
}
</code></pre>
<p>Repository &#x63A5;&#x53E3;&#x5B9E;&#x73B0;: Spring Data Elasticsearch repository CURD&#x5168;&#x8986;&#x76D6;&#xFF0C;Spring Data&#x505A;&#x7684;&#x8DB3;&#x591F;&#x597D;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x6B64;&#x5904;&#x4EE3;&#x7801;&#x975E;&#x5E38;&#x7B80;&#x5355;</p>
<pre><code class="lang-java">
<span class="hljs-meta">@Repository</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">HumanRepository</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">ElasticsearchRepository</span>&lt;<span class="hljs-title">Human</span>, <span class="hljs-title">String</span>&gt; </span>{

}
</code></pre>
<h3 id="&#x5B58;&#x50A8;&#x6570;&#x636E;&#x5230;es">&#x5B58;&#x50A8;&#x6570;&#x636E;&#x5230;es</h3>
<p>&#x901A;&#x8FC7;&#x5207;&#x9762;&#x626B;&#x63CF;&#x5DF2;&#x7ECF;&#x5F00;&#x542F;es&#x652F;&#x6301;&#x7684;&#x5B9E;&#x4F53;&#xFF0C;&#x5728;&#x5B8C;&#x6210;&#x5B9E;&#x4F53;&#x81EA;&#x8EAB;&#x5B58;&#x50A8;&#x540E;&#xFF0C;&#x901A;&#x8FC7;&#x5F02;&#x6B65;&#x7684;&#x65B9;&#x5F0F;&#x5B58;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#x5230;es&#x3002;</p>
<pre><code class="lang-java">
<span class="hljs-meta">@Aspect</span>
<span class="hljs-meta">@Component</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ESAspect</span>
</span>{
    <span class="hljs-meta">@Autowired</span>
    IHumanService esService;
    <span class="hljs-comment">/**
     * &#x5F02;&#x6B65;&#x5F80;es&#x4E2D;&#x4FDD;&#x5B58;&#x6570;&#x636E;
     * <span class="hljs-doctag">@param</span> point
     */</span>
    <span class="hljs-meta">@AfterReturning</span>(value = <span class="hljs-string">&quot;execution(* net.ibizsys.sample.mng.core.*.service.*.create(..))&quot;</span>)
    <span class="hljs-meta">@SneakyThrows</span>
    <span class="hljs-meta">@Async</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">create</span><span class="hljs-params">(JoinPoint point)</span></span>{
        Human esDomain=<span class="hljs-keyword">new</span> Human();
        Object [] args = point.getArgs();
        <span class="hljs-keyword">if</span>(ObjectUtils.isEmpty(args) || args.length==<span class="hljs-number">0</span>)
            <span class="hljs-keyword">return</span>;
        Object serviceParam =args[<span class="hljs-number">0</span>];
        CachedBeanCopier.copy(serviceParam,esDomain);
        esService.create(esDomain);
        <span class="hljs-keyword">return</span>;
    }
}
</code></pre>
<h3 id="&#x67E5;&#x8BE2;es&#x4E2D;&#x7684;&#x6570;&#x636E;">&#x67E5;&#x8BE2;es&#x4E2D;&#x7684;&#x6570;&#x636E;</h3>
<p>&#x63D0;&#x4F9B;&#x670D;&#x52A1;&#x63A5;&#x53E3;&#xFF0C;&#x4EE5;&#x4F9B;&#x4ECE;es&#x4E2D;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#xFF0C;&#x4EE5;get&#x4E3A;&#x4F8B;&#xFF0C;fetch&#x540C;&#x7406;&#x3002;</p>
<pre><code class="lang-java">
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HumanResource</span> </span>{
    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">public</span> HumanESMapping humanEsMapping;
    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">public</span> IHumanService esService;

    <span class="hljs-meta">@RequestMapping</span>(method = RequestMethod.GET, value = <span class="hljs-string">&quot;/humen/{human_id}/es&quot;</span>)
    <span class="hljs-function"><span class="hljs-keyword">public</span> ResponseEntity&lt;HumanDTO&gt; <span class="hljs-title">ESGet</span><span class="hljs-params">(@PathVariable(<span class="hljs-string">&quot;human_id&quot;</span>)</span> String human_id) </span>{
        net.ibizsys.sample.mng.core.es.domain.Human domain=esService.get(human_id);
        HumanDTO dto = humanEsMapping.toDto(domain);
        <span class="hljs-keyword">return</span> ResponseEntity.status(HttpStatus.OK).body(dto);
    }
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="security.html" class="navigation navigation-prev " aria-label="Previous page: 安全">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="cache.html" class="navigation navigation-next " aria-label="Next page: 使用Redis的两级缓存">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Elasticsearch查询性能提升","level":"1.6.2","depth":2,"next":{"title":"使用Redis的两级缓存","level":"1.6.3","depth":2,"path":"option/cache.md","ref":"option/cache.md","articles":[]},"previous":{"title":"安全","level":"1.6.1","depth":2,"path":"option/security.md","ref":"option/security.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"option/es.md","mtime":"2020-10-08T05:43:21.966Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-10-08T05:59:13.818Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

